package com.original.simuladoresws.service.impl;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.original.simuladoresws.dao.SimulationDao;
import com.original.simuladoresws.dao.impl.SimulationDaoImpl;
import com.original.simuladoresws.entities.TbSimulation;
import com.original.simuladoresws.service.SimulationService;

@Repository("simulationService")
public class SimulationServiceImpl implements SimulationService {
	SimulationDao simulasionDao = new SimulationDaoImpl();
	@Override
	public Integer save(TbSimulation simulation) {
		return (Integer) simulasionDao.create(simulation);
	}
	
	@Override
	public List<TbSimulation> getAllSimulation() {
		return simulasionDao.read(TbSimulation.class);
	}

	@Override
	public Integer getId() {
		List<TbSimulation> ls = simulasionDao.lastestObject(TbSimulation.class);
		Integer idReturn = 1;
		if (ls != null && ls.size() > 0) {
			TbSimulation obj = ls.get(ls.size() - 1);
			idReturn = obj.getId()  + 1;
		}
		return idReturn;
	}
	
}
